package com.mmall.controller;

import com.mmall.common.ServerResponse;
import com.mmall.exception.ParamException;
import com.mmall.param.TestVo;
import com.mmall.util.BeanValidatorUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author wangtenu
 * @Create 2018-03-06-9:41
 */
@Controller
@Slf4j
@RequestMapping("/test")
public class TestController {

    @RequestMapping("/hello.json")
    @ResponseBody
    public ServerResponse hello(){
        log.info("hello");
        throw new ParamException("lalalalal");
    }


    @RequestMapping("/validate.json")
    @ResponseBody
    public ServerResponse validate(TestVo vo) throws ParamException{
        log.info("validate");
        BeanValidatorUtil.check(vo);
        return ServerResponse.createBySuccessMessage("校验成功");
    }
}
